package co.edu.eam.iso.view.treetable;

import co.edu.eam.iso.evaluated.ProductEvaluated;

/**
 * @author Giovanny Ramirez Blandon
 * @version 1.0
 */
public class Model extends AbstractTreeTableModel implements
		TreeTableModel {

	static protected String[] cNames = { "Evaluación", "Calidad", "(%)" };
	static protected Class[] cTypes = { TreeTableModel.class, String.class, String.class };

	public Model(ProductEvaluated productEvaluated) {
		super(productEvaluated);
	}

	public Object getChild(Object parent, int index) {
		return getChildren(parent)[index];
	}
	
	private Object[] getChildren(Object node) {
		Node qualityNode = new Node(node);
		return qualityNode.getChildren();
	}

	public int getChildCount(Object parent) {
		Object[] children = getChildren(parent);
		return (children == null) ? 0 : children.length;
	}

	public int getColumnCount() {
		return cNames.length;
	}

	public String getColumnName(int column) {
		return cNames[column];
	}

	public Class getColumnClass(int column) {
		return cTypes[column];
	}

	public Object getValueAt(Object node, int column) {
		Node qualityNode = new Node(node);
		return qualityNode.getInfo(column);
	}

}